<?php 
include '../../../php/conn.php'; 
if ($con) {
	if ($_POST) {
		
		$gradeid= $_POST['gradeid'];
		$ClassAndGrade= $_POST['ClassAndGrade'];
		$TMid= $_POST['TMid'];
		$DTid= $_POST['DTid']; 
		$CMClassTime = date('y-m-d H:I:S');
	 //查询是否添加过
//	 SELECT *
//FROM `subjectstable`
//WHERE STbname = '语文'
		$masql = "SELECT * FROM classmanagement WHERE ClassAndGrade='$ClassAndGrade'"; 
		$msy=mysql_query($masql); 
		if ($msy) {
			$mynamesql = mysql_num_rows($msy);
			if ($mynamesql==1) {
				 
				//已有该数据
				echo '{"status":"100"}';
				
			} else {
				 
				 //没有此数据时执行新增
				$sql = "INSERT INTO `classmanagement`(`CMid`, `gradeid`, `ClassAndGrade`, `TMid`, `DTid`, `CMClassTime`, `CMGraduate`)
				 VALUES (0,$gradeid,'$ClassAndGrade',$TMid,$DTid,'$CMClassTime',0)";
				//执行
				$rs = mysql_query($sql);
				if ($rs) { 
					 //新增成功 
					 echo '{"status":"200"}';
				}else
					{
						//新增失败
				echo '{"status":"404"}';
					}
				
				
				
			} 

		} else {
			//sql语句错误
			echo '{"status":"501"}';
		}
	 
	}    
}
//关闭数据库
mysql_close($con);
?>